package com.kuangstudy.thread.demo3;

/**
 * @author Losca
 * @date 2021/7/19 20:25
 * 线程优先级 1~10
 * 优先级低只是意味着获得调度的概念低并不是优先级低就不会被调用了 这都是看cpu的调度
 */
public class Demo5 {
    public static void main(String[] args) {
        System.out.println(Thread.currentThread().getName()+"===>"+Thread.currentThread().getPriority());
        MyThread myThread = new MyThread();
        Thread t1 = new Thread(myThread,"1");
        Thread t2 = new Thread(myThread,"2");
        Thread t3 = new Thread(myThread,"3");
        Thread t4 = new Thread(myThread,"4");

        t1.start();

        t2.setPriority(1);
        t2.start();

        t3.setPriority(4);
        t3.start();

        t4.setPriority(Thread.MAX_PRIORITY);//10
        t4.start();
    }
}

class MyThread implements Runnable{

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"===>"+Thread.currentThread().getPriority());
    }
}
